package com.qingcheng.dao;

import com.qingcheng.pojo.order.OrderItem;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface OrderItemMapper extends Mapper<OrderItem> {

    @Select("SELECT\n" +
            "\toi.id,\n" +
            "\tsk.name,\n" +
            "\tsk.price,\n" +
            "\tsp.sn,\n" +
            "\tsk.spec,\n" +
            "\toi.num,\n" +
            "\tsk.num knum \n" +
            "FROM\n" +
            "\ttb_order_item oi\n" +
            "\tLEFT JOIN qingcheng_goods.tb_spu sp ON oi.spu_id=sp.id\n" +
            "\tLEFT JOIN qingcheng_goods.tb_sku sk ON oi.sku_id = sk.id\n" +
            "WHERE\n" +
            "\torder_id = #{orderId}")
    public List<Map> findOrderItemByOrderId(String orderId);


    @Select("SELECT\n" +
            "\toi.id,\n" +
            "\tsk.NAME name,\n" +
            "\tsk.price,\n" +
            "\tsk.image,\n" +
            "\tsp.sn,\n" +
            "\tsk.spec,\n" +
            "\toi.num,\n" +
            "\toi.post_fee,\n" +
            "\tb.name bname,\n" +
            "\tsk.num knum \n" +
            "FROM\n" +
            "\ttb_order_item oi\n" +
            "\tLEFT JOIN qingcheng_goods.tb_spu sp ON oi.spu_id = sp.id\n" +
            "\tLEFT JOIN qingcheng_goods.tb_sku sk ON oi.sku_id = sk.id\n" +
            "\tLEFT JOIN qingcheng_goods.tb_brand b ON b.id = sp.brand_id\n" +
            " \n" +
            "WHERE\n" +
            "\torder_id = #{orderId}")
    public List<Map> findLookOrderItem(String orderId);

    @Select("SELECT\n" +
            "\toi.id,\n" +
            "\toi.order_id orderId,\n" +
            "\tsp.image,\n" +
            "\tb.name bname,\n" +
            "\tsk.NAME,\n" +
            "\tsk.price,\n" +
            "\tsp.sn,\n" +
            "\tsk.spec,\n" +
            "\toi.num,\n" +
            "\tsk.num knum, \n" +
            "\toi.money money \n" +
            "FROM\n" +
            "\t\n" +
            "\ttb_order_item oi\n" +
            "\tLEFT JOIN qingcheng_goods.tb_spu sp ON oi.spu_id = sp.id\n" +
            "\tLEFT JOIN qingcheng_goods.tb_sku sk ON oi.sku_id = sk.id\n" +
            "\tLEFT JOIN qingcheng_goods.tb_brand b ON b.id = sp.brand_id \n" +
            "WHERE\n" +
            "\torder_id = #{order_id}")
    public List<Map> findOrderItemById(String order_id);
}
